package com.zfsmart.projectdemo.asset.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zfsmart.component.common.bean.restful.entity.RespMsg;
import com.zfsmart.projectdemo.asset.entity.User;
import com.zfsmart.projectdemo.asset.entity.UserQuery;
import com.zfsmart.projectdemo.asset.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xuetieqi
 * @since 2021-09-09
 */
@RestController
@RequestMapping("/asset/user")
public class UserController {

    @Autowired
    UserService userService;

    @ApiOperation("test")
    @PostMapping("/test")
    public RespMsg<User> test(@RequestBody UserQuery userQuery) {
        Page<User> page = new Page<>(userQuery.getCurrent(), userQuery.getSize());
        //测试deleted
//        User insert = User.builder().age(1).name("xuetieqi").email("dfgaf@qq.com").build();
//        userService.save(insert);
//        User update = userService.getById(23L);
//        update.setAge(1);
//        userService.updateById(update);
//        userService.removeById(1);
//        return RespMsg.success(userService.selectUserPage(page));
        return RespMsg.success(userService.getById(1));
    }
}

